using Mapster;
using SmartAgricultureService.Tables;

namespace SmartAgricultureService.Models.Tables
{
    public class ReportInfo
    {
        public string AreaId { get; set; }
        public string AreaCode { get; set; }
        public DateTime ReportDate { get; set; }
        public List<ReportDetailInfo> ReportDetails { get; set; }
        public static TypeAdapterConfig GetAdapterConfig()
        {
            var config = new TypeAdapterConfig();
            return config.ForType<ReportEntry, ReportInfo>()
                .Map(dest => dest.AreaId, src => src.AreaId)
                .Map(dest => dest.AreaCode, src => src.AreaCode)
                .Map(dest => dest.ReportDate, src => src.ReportDate)
                .Map(dest => dest.ReportDetails, src => src.ReportDetails.Adapt<List<ReportDetailInfo>>(ReportDetailInfo.GetAdapterConfig()))
                .Config;
        }
    }
}